package com.dt76.smallloanbackendservice.service.yaozhao.Impl;

import com.dt76.smallloanbackendservice.mapper.yaozhao.UpcomingExpireMapper;
import com.dt76.smallloanbackendservice.pojo.yaozhao.UpcomingExpire;
import com.dt76.smallloanbackendservice.service.yaozhao.UpcomingExpireService;
import com.dt76.smallloanbackendservice.utils.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class UpcomingExpireServiceImpl implements UpcomingExpireService {
    @Autowired
    private UpcomingExpireMapper upcomingExpireMapper;
    @Override
    public List<UpcomingExpire> qryAll() {
        return upcomingExpireMapper.qryAll();
    }

    @Override
    public Page qryPageAll(int pageIndex, String userName, String phoneNumber, String loanId, String ContractId) {
        Page page = new Page();
        page.setPageIndex(pageIndex);//每次更新当前页
        //更新总条数
        page.setTotalCount(upcomingExpireMapper.qryCount(userName,phoneNumber,loanId,ContractId));
        List<UpcomingExpire> upcomingExpireList = upcomingExpireMapper.qryPageAll((page.getPageIndex()-1)*page.getPageSize(),
                page.getPageSize(),userName,phoneNumber,loanId,ContractId);
        page.setRows(upcomingExpireList);
        return page;
    }
}
